﻿
<template>
<div class="card-fill layout-padding">
<el-card shadow="hover" class="layout-padding-auto" >
  <div>
    <el-form ref="formRefMaterialBindRecord" :model="stateMaterialBindRecord.vmModel" label-width="100px">
      <el-row>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_LineCode_FormItem" prop="Entity.LineCode" :label="$t('message.autotrans._Model_MaterialBindRecord_lineCode')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_MaterialBindRecord_lineCode')}), trigger: 'blur' }]" >
            <el-input v-model="stateMaterialBindRecord.vmModel.Entity.LineCode" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_StationCode_FormItem" prop="Entity.StationCode" :label="$t('message.autotrans._Model_MaterialBindRecord_stationCode')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_MaterialBindRecord_stationCode')}), trigger: 'blur' }]" >
            <el-input v-model="stateMaterialBindRecord.vmModel.Entity.StationCode" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_OrderCode_FormItem" prop="Entity.OrderCode" :label="$t('message.autotrans._Model_MaterialBindRecord_orderCode')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_MaterialBindRecord_orderCode')}), trigger: 'blur' }]" >
            <el-input v-model="stateMaterialBindRecord.vmModel.Entity.OrderCode" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_ScheduleCode_FormItem" prop="Entity.ScheduleCode" :label="$t('message.autotrans._Model_MaterialBindRecord_scheduleCode')">
            <el-input v-model="stateMaterialBindRecord.vmModel.Entity.ScheduleCode" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_SnNumber_FormItem" prop="Entity.SnNumber" :label="$t('message.autotrans._Model_MaterialBindRecord_snNumber')">
            <el-input v-model="stateMaterialBindRecord.vmModel.Entity.SnNumber" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_AssemblyMaterialCode_FormItem" prop="Entity.AssemblyMaterialCode" :label="$t('message.autotrans._Model_MaterialBindRecord_assemblyMaterialCode')">
            <el-input v-model="stateMaterialBindRecord.vmModel.Entity.AssemblyMaterialCode" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_AssemblyMaterialQty_FormItem" prop="Entity.AssemblyMaterialQty" :label="$t('message.autotrans._Model_MaterialBindRecord_assemblyMaterialQty')">
            <el-input v-model="stateMaterialBindRecord.vmModel.Entity.AssemblyMaterialQty" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_AssemblySort_FormItem" prop="Entity.AssemblySort" :label="$t('message.autotrans._Model_MaterialBindRecord_assemblySort')">
            <el-input v-model="stateMaterialBindRecord.vmModel.Entity.AssemblySort" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_AssemblyTime_FormItem" prop="Entity.AssemblyTime" :label="$t('message.autotrans._Model_MaterialBindRecord_assemblyTime')">
            <el-input v-model="stateMaterialBindRecord.vmModel.Entity.AssemblyTime" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_AssemblyMaterialName_FormItem" prop="Entity.AssemblyMaterialName" :label="$t('message.autotrans._Model_MaterialBindRecord_assemblyMaterialName')">
            <el-input v-model="stateMaterialBindRecord.vmModel.Entity.AssemblyMaterialName" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_AssemblyMaterialVersion_FormItem" prop="Entity.AssemblyMaterialVersion" :label="$t('message.autotrans._Model_MaterialBindRecord_assemblyMaterialVersion')">
            <el-input v-model="stateMaterialBindRecord.vmModel.Entity.AssemblyMaterialVersion" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_AssemblyMaterialSn_FormItem" prop="Entity.AssemblyMaterialSn" :label="$t('message.autotrans._Model_MaterialBindRecord_assemblyMaterialSn')">
            <el-input v-model="stateMaterialBindRecord.vmModel.Entity.AssemblyMaterialSn" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_MaterialBatchNo_FormItem" prop="Entity.MaterialBatchNo" :label="$t('message.autotrans._Model_MaterialBindRecord_materialBatchNo')">
            <el-input v-model="stateMaterialBindRecord.vmModel.Entity.MaterialBatchNo" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_Uploadflag_FormItem" prop="Entity.Uploadflag" :label="$t('message.autotrans._Model_MaterialBindRecord_uploadflag')">
            <el-select v-model="stateMaterialBindRecord.vmModel.Entity.Uploadflag" clearable>
               <el-option :key="1" :value=true :label="$t('message._system.common.vm.tips_bool_true')"></el-option>
               <el-option :key="0" :value=false :label="$t('message._system.common.vm.tips_bool_false')"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
      </el-row>

      <div style="text-align:right;">
        <WtmButton @click="onSubmitMaterialBindRecord"  type="primary" :button-text="$t('message.autotrans.SysSubmit')" style="margin-top:15px;"/>

        <WtmButton @click="onCloseMaterialBindRecord"  type="primary" :button-text="$t('message.autotrans.SysClose')" style="margin-top:15px;"/>

      </div>

    </el-form>

  </div>

</el-card>
</div>
</template>


<script setup lang="ts" name="message.autotrans._PageRecordMaterialBindRecordEdit;false">
import {  ElMessageBox, ElMessage,ElLoading } from 'element-plus';
import { defineAsyncComponent,reactive, ref, getCurrentInstance, onMounted, nextTick } from 'vue';
import { materialbindrecordApi } from '/@/api/record/materialbindrecord';
import other from '/@/utils/other';
import fileApi from '/@/api/file';
import { useRouter } from "vue-router";
const ci = getCurrentInstance() as any;


// 定义变量内容
const formRefMaterialBindRecord = ref();
const stateMaterialBindRecord = reactive({
    vmModel: {
	  Entity:{
        LineCode: '',
        StationCode: '',
        OrderCode: '',
        ScheduleCode: '',
        SnNumber: '',
        AssemblyMaterialCode: '',
        AssemblyMaterialQty: '',
        AssemblySort: '',
        AssemblyTime: '',
        AssemblyMaterialName: '',
        AssemblyMaterialVersion: '',
        AssemblyMaterialSn: '',
        MaterialBatchNo: '',
        Uploadflag: undefined,
        ID:null,
      },

	},
    
});

// 取消
const onCloseMaterialBindRecord = () => {
    closeDialog();
};

// 提交
const onSubmitMaterialBindRecord = () => {
 	const loadingInstance = ElLoading.service({
		lock: true,
		text: '正在提交中，请等待。。。',
		background: 'rgba(0, 0, 0, 0.7)',
	});
   formRefMaterialBindRecord.value?.validate((valid: boolean, fields: any) => {
		if (valid) {
            materialbindrecordApi().edit(stateMaterialBindRecord.vmModel).then(() => {
                ElMessage.success(ci.proxy.$t('message._system.common.vm.submittip'));
                emit('refresh');
                closeDialog();
            }).catch((error) => {
                other.setFormError(ci, error);
            }).finally(() => {
			loadingInstance.close();
		    })
		}
	})
};

// 页面加载时
onMounted(() => {
    
    if (ci.attrs["wtmdata"]) {
		stateMaterialBindRecord.vmModel.Entity.ID = ci.attrs["wtmdata"].ID;
	}
	else if (useRouter().currentRoute.value.query.id) {
		stateMaterialBindRecord.vmModel.Entity.ID = useRouter().currentRoute.value.query.id as any;
	}
	materialbindrecordApi().get(stateMaterialBindRecord.vmModel.Entity.ID ?? "").then((data: any) => other.setValue(stateMaterialBindRecord.vmModel, data));
});

// 定义子组件向父组件传值/事件
const emit = defineEmits(['refresh','closeDialog']);
// 关闭弹窗
const closeDialog = () => {
    emit('closeDialog');
};
// 暴露变量
defineExpose({

});
</script>

<style scoped lang="scss">

</style>

